package com.example.chatweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.chatweb.dto.BigBaseSearchDTO;
import com.example.chatweb.entity.BigBase;
import com.example.chatweb.entity.PersonalBase;
import com.example.chatweb.mapper.BigBaseMapper;
import com.example.chatweb.service.BigBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.Collections;
import java.util.List;

@Service
public class BigBaseServiceImpl extends ServiceImpl<BigBaseMapper,BigBase> implements BigBaseService {

    @Autowired
    private BigBaseMapper bigBaseMapper;


    @Override
    public List<BigBase> findPdfsByConditions(BigBaseSearchDTO searchDTO) {
        QueryWrapper<BigBase> queryWrapper = new QueryWrapper<>();

        // 根据DTO中的属性设置查询条件
        if (searchDTO.getTitle() != null && !searchDTO.getTitle().isEmpty()) {
            queryWrapper.like("title", searchDTO.getTitle());
        }

        if (searchDTO.getKeyword() != null && !searchDTO.getKeyword().isEmpty()) {
            queryWrapper.like("keyword", searchDTO.getKeyword());
        }

        if (searchDTO.getAuthor() != null && !searchDTO.getAuthor().isEmpty()) {
            queryWrapper.like("author", searchDTO.getAuthor());
        }

        if (searchDTO.getAffiliation() != null && !searchDTO.getAffiliation().isEmpty()) {
            queryWrapper.like("affiliation", searchDTO.getAffiliation());
        }

        if (searchDTO.getPublicTimeFrom() != null && searchDTO.getPublicTimeTo() != null) {
            queryWrapper.between("public_time", searchDTO.getPublicTimeFrom(), searchDTO.getPublicTimeTo());
        }

        if (searchDTO.getConferenceName() != null && !searchDTO.getConferenceName().isEmpty()) {
            queryWrapper.like("conference_name", searchDTO.getConferenceName());
        }

        if (searchDTO.getConferenceTimeFrom() != null && searchDTO.getConferenceTimeTo() != null) {
            queryWrapper.between("conference_time", searchDTO.getConferenceTimeFrom(), searchDTO.getConferenceTimeTo());
        }

        if (searchDTO.getStaticUrl() != null && !searchDTO.getStaticUrl().isEmpty()) {
            queryWrapper.like("static_url", searchDTO.getStaticUrl());
        }

        // 执行查询
        return bigBaseMapper.selectList(queryWrapper);
    }

}
